package com.sam.leetcode

import java.util.*
import kotlin.math.min


class Computer (
    var mainBoard: String = "苹果主板", // 自家定制的主板
    var display: String? = "2K Retina",// 显示器 2K+
    var OS: String = "MacOS" // 自带 Mac
)

fun main() {
    Computer(
            mainBoard = "Intel 主板",
            OS = "Windows"
    )

    print(String.format(Locale.US,"%tB", Date()))
}


//fun main() {
//    print(eraseOverlapIntervals(arrayOf(intArrayOf(1, 2), intArrayOf(2, 3))))
//}
fun eraseOverlapIntervals(intervals: Array<IntArray>): Int {
    intervals.sortBy { it[0] }
    // 以 dp[i] 以 i 结尾最大的不相交个数 ，result = size - max(dp)
    val dp = IntArray(intervals.size)

    for (i in intervals.indices) {
        dp[i] = 1
        for (j in i - 1 downTo 0) {
            if (intervals[j][1] < intervals[i][0]) {
                dp[i] = Math.max(dp[j] + 1, dp[i])
                break
            }
        }
    }

    return dp.size - (dp.maxOrNull() ?: 0)
}